package com.mall.group_booking.controller;

import com.mall.common.response.CommonResponse;
import com.mall.entity.groupbooking.GbItem;
import com.mall.group_booking.service.BookingItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author White
 * @version 1.0
 * @email 616769721@qq.com
 * @date 2021/7/29 20:58
 */
@RestController
@RequestMapping("/bookingItem")
@CrossOrigin
public class BookingItemController {

    @Autowired
    private BookingItemService bookingItemService;

    @GetMapping("addItemToRedis")
    public void addItemToRedis(){
        bookingItemService.addItemToRedis();
    }

    /**
     * 查询拼团商品列表
     * @return
     */
    @GetMapping("/findItemList")
    public List<GbItem> findItemList(){
        return bookingItemService.findItemList();
    }

    /**
     * 单独购买功能
     * @param specItemId
     * @param uid
     * @return
     */
    @PostMapping("/addOrder")
    public CommonResponse addOrder(Long specItemId,Long uid){
        return bookingItemService.addOrder(specItemId,uid);
    }
}
